package com.central.apps.handler.po;

import cn.hutool.core.map.MapUtil;
import com.central.app.service.HandlerService;
import com.central.apps.handler.base.LvBaseHandler;
import com.central.bizcommon.model.flow.FlowNode;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 采购申请
 */
@Component
public class prHandler extends LvBaseHandler {

    @Autowired
    private HandlerService handlerService;

    /**
     * 自定义审批人
     * @param app
     * @param id
     * @param flowNode
     * @param vars
     * @return
     * @throws Exception
     */
    public String addFlowCandidate(String app, Long id, FlowNode flowNode, Map<String, Object> vars) throws Exception {
        //定义一个存放人员的字符串
        String executer = null;
        List<Map<String, Object>> list = handlerService.findBySql
                (" select user.username from bl_cgdan po " +
                        "  left join sys_user user on po.createuser=user.id " +
                        " where po.id ='"+id+"'");
        String username = MapUtil.getStr(list.get(0), "username");//创建人

        //转入仓库管理员
        if (flowNode.getId().equals("end")) {
            if (username!=null&&!username.equals("")){
                executer=username;
            }
        }
        return executer;
    }

}
